n=int(input())
d=int(input())
e=int(input())*5
q=n//e
ans=n
for i in range(q+1):
h=(n-i*e)%d
ans=min(ans,h)
print(ans)
#include <cstdio>
typedef long long ll;
int main(){
ll n; scanf("%lld", &n);
ll d, h; scanf("%lld %lld", &d, &h);
h *= 5;
ll mn(n);
for(ll p = 0; p * h <= n; p++){
ll rem = (n - p * h) % d;
mn = (mn < rem) ? mn : rem;
}
printf("%lld\n", mn);
return 0;
}
Split houses | Divisible |
Three primes | Coprimes |
Cost of balloons | One String No Trouble |
Help Jarvis! | Lift queries |
Goki and his breakup | Ali and Helping innocent people |
Book of Potion making | Duration |
Birthday Party | e-maze-in |
Bricks Game | Char Sum |
Two Strings | Anagrams |
Prime Number | Lexical Sorting Reloaded |
1514A - Perfectly Imperfect Array | 580A- Kefa and First Steps |
1472B- Fair Division | 996A - Hit the Lottery |
MSNSADM1 Football | MATCHES Playing with Matches |
HRDSEQ Hard Sequence | DRCHEF Doctor Chef |
559. Maximum Depth of N-ary Tree | 821. Shortest Distance to a Character |